package cn.bone.motan.chuandian.gateway.service;

import cn.bone.motan.common.MoRequest;
import cn.bone.motan.common.MoResponse;
import cn.bone.motan.demo1.api.RemoteApi;
import cn.bone.motan.demo1.api.ServerApi;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by MD-01 on 2017/3/13.
 */
@Service
public class RemoteService implements RemoteApi{

    private Logger logger = org.slf4j.LoggerFactory.getLogger("cd-gateway");

    @Resource(name="server")
    private ServerApi serverApi;

    @Override
    public MoResponse execute(MoRequest request) {

        logger.info("收到来自其他域的消息.转发给自己的server处理");

        if(request==null){
            return MoResponse.error("参数不能为空");
        }
        String from = request.getFrom();
        //判断from是来自于自己的上级
        return serverApi.execute(request);
    }
}
